<?php /*a:2:{s:55:"F:\tp-layui\tp5\application\admin\view\user\listcy.html";i:1621047569;s:55:"F:\tp-layui\tp5\application\admin\view\public\base.html";i:1620829072;}*/ ?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理系统</title>
    <link rel="stylesheet" href="/static/layui/layui/css/layui.css">

</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">我的后台管理系统</div>
            <!-- 头部区域航） -->
             <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item  
                "><a href="<?php echo url('admin/admin/admin'); ?>"><i class="layui-icon layui-icon-home">&nbsp;&nbsp;</i>首页</a></li>
                <!-- <li class="layui-nav-item"><a href="">nav 2</a></li>
                <li class="layui-nav-item"><a href="">nav 3</a></li> -->
                <li class="layui-nav-item">
                    <a href="javascript:;"><i class="layui-icon layui-icon-set">&nbsp;&nbsp;</i>其他系统</a>
                    <dl class="layui-nav-child">
                        <dd><a href="">邮件管理</a></dd>
                        <dd><a href="">消息管理</a></dd>
                        <dd><a href="">授权管理</a></dd>
                    </dl>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img"> 用户
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="">基本资料</a></dd>
                        <dd><a href="">退出登录</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="">登录</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域 -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item ">
                        <a class="" href="javascript:;"><i class="layui-icon layui-icon-user">&nbsp;&nbsp;</i>用户管理</a>
                        <dl class="layui-nav-child">
                            <dd class=" 
                            "><a href="javascript:;">管理员</a></dd>
                            <dd class=" 
                                "><a href="<?php echo url('admin/user/listcy'); ?>">学员管理</a></dd>
                            <!-- <dd><a href="javascript:;">menu item 1-3</a></dd>
                            <dd><a href="">the links</a></dd> -->
                        </dl>
                    </li>
                    <li class="layui-nav-item ">
                        <a href="javascript:;"><i class="layui-icon layui-icon-read ">&nbsp;&nbsp;</i>试题管理</a>
                        <dl class="layui-nav-child">
                            <dd class="{ 
                            }"><a href="<?php echo url('admin/exam/list1'); ?>">试题列表</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item 
                        
                     "><a href="javascript:;"><i class="layui-icon layui-icon-dialogue">&nbsp;&nbsp;</i>留言管理</a></li>

                </ul>
            </div>
        </div>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">
<div class="demoTable">
    搜索ID
    <div class="layui-inline">
        <input class="layui-input" name="id" id="demoReload" autocomplete="off">
    </div>
    <button class="layui-btn" data-type="reload" id="btnsearch">搜索</button>
</div>
<table id="user" lay-filter="user" class="layui-bg-green"></table>


            </div>
        </div>

        <div class="layui-footer">
            <!-- 底部固定区域 -->
            底部固定区域
        </div>
    </div>

    <script src="/static/layui/layui/layui.js"></script>
    <script>
        //JavaScript代码区域
        layui.use('element', function() {
            var element = layui.element;

        });
    </script>
    
<script type="text/javascript">
    layui.use('table', function() { 
        var table = layui.table;
        var $ = layui.$;
        table.render({
            elem: '#user',
            height: 400,
            url: '<?php echo url("admin/user/getUserData"); ?>',
            cols: [
                [{
                    field: 'id',
                    width: 80,
                    title: 'ID',
                    sort: true
                }, {
                    field: 'username',
                    title: '用户名'
                }, {
                    field: 'email',
                    title: '邮箱'
                }, {
                    field: 'role',
                    title: '角色',
                    edit: "text",
                    templet: function(d) {
                        if (d.role == 0) {
                            return '<span>成员</span>';
                        } else {
                            return '<span>管理员</span>';
                        }

                    }
                }, {
                    field: 'status',
                    title: '状态',
                    edit: "text",
                    templet: function(d) {
                        if (d.status == 1) {
                            return '<span style="color:green">正常</span>';
                        } else {
                            return '<span style="color:red">禁用</span>';
                        }
                    }
                }, {
                    field: 'score',
                    title: '学分',
                    sort: true
                }, {
                    field: 'ip',
                    title: 'ip'
                }, ]
            ],
            page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'],
                limit: 10, //每个表格显示几条记录
                limits: [5, 10, 15], //每页显示几条
                groups: 3, //显示一个连续页码
                frist: true, //不显示首页
                last: false, //不显示尾页 
            },
            id: 'idTest'
        });
        $('#btnsearch').click(function() {
            // layer.alert($('#demoReload').val());
            // table.reload('idTest', {
            //     where: ,
            //     page: {
            //         curr: 1
            //     }

            // });

            table.reload('idTest', {
                where: { //设定异步数据接口的额外参数，任意设
                    id: $('#demoReload').val()
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            }); //只重载数据

        })
        table.on('edit(user)', function(obj) {
            var value = obj.value, //修改后的值
                data = obj.data, //得到所在行的键值 
                field = obj.field; //字段
            // layer.msg('[ID:' + data.id + '] ' + field + ' 字段更改为 ' + value);
            // layer.confirm("确认修改" + '[ID:' + data.id + '] ' + field + ' 字段更改为 ' + value, function() {
            layer.confirm("真的要修改么？", function() {
                $.ajax({
                    type: "get",
                    url: "<?php echo url('admin/user/edit'); ?>",
                    // data: "id=" + data.id + "&field=" + field + "&value" + value
                    data: data,
                    dataType: "json",
                    success: function(data) {
                        if (data.code == 200) {
                            layer.msg(data.msg, {
                                time: 500
                            }, function() {
                                window.location.reload();
                            })
                        } else {
                            layer.msg(data.msg, {
                                time: 1000
                            }, function() {
                                window.location.reload();

                            })
                        }
                    }
                })
            })
        });


    });
</script>

</body>

</html>